package com.sugon.controller;

import com.alibaba.fastjson.JSON;
import com.sugon.dto.Info;
import com.sugon.service.IdentityCardService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @author: jichenglu
 * @create: 2019-12-18 10:44
 **/
@RestController
@RequestMapping(value="/idcard")
public class IdentityCardController {

    @Autowired
    private IdentityCardService identityCardService;

    @ApiOperation("拆分身份证")
    @RequestMapping(value="/splitIdentityCard")
    public Object splitIdentityCard(@RequestBody String id){
        if(id.contains("\"")){
            id = JSON.parse(id).toString();
        }
        //如果身份证是15位则转18位
        id = identityCardService.toEighteen(id);
        //解析身份证
        String data = identityCardService.splitIdentityCard(id);
        System.out.println();
        return JSON.toJSONString(data);
    }
}
